//
//  IndexDataFactory.cpp
//  Chart
//
//  Created by CaoJun on 13-6-13.
//
//

#include "IndexDataFactory.h"
#include "YTXChartCommon.h"
#include <map>
#include <cmath>

using namespace std;
using namespace ytx;

//ADDIndex:
IndexDataFactory::IndexDataFactory(Quotation * data):data(data), ma(NULL), bollin(NULL), tj(NULL), economicCalendar(NULL), volume(NULL), macd(NULL), kdj(NULL), rsi(NULL), bias(NULL), qk(NULL), qkt(NULL), cci(NULL), gameMatrix(NULL), hjjt(NULL)
{

}

IndexDataFactory::IndexDataFactory():ma(NULL), bollin(NULL), tj(NULL), economicCalendar(NULL), volume(NULL), macd(NULL), kdj(NULL), rsi(NULL), bias(NULL), qk(NULL), qkt(NULL), cci(NULL), gameMatrix(NULL), hjjt(NULL)
{

}
//ADDIndex:
IndexDataFactory::~IndexDataFactory(){
    SAFEDELETE(ma);
    SAFEDELETE(bollin);
    SAFEDELETE(tj);
    SAFEDELETE(economicCalendar);
    SAFEDELETE(volume);
    SAFEDELETE(tuov);
    SAFEDELETE(macd);
    SAFEDELETE(kdj);
    SAFEDELETE(rsi);
    SAFEDELETE(bias);
    SAFEDELETE(qk);
    SAFEDELETE(qkt);
    SAFEDELETE(cci);
    SAFEDELETE(gameMatrix);
    SAFEDELETE(hjjt);
}

Quotation * IndexDataFactory::getData()
{
    return data;
}

void IndexDataFactory::setData(Quotation * data)
{
    this->data = data;
}

void IndexDataFactory::create(const map<IndexType::IndexType, ytx::IndexConfig> & indexConfigMap)
{
    for (map<IndexType::IndexType, ytx::IndexConfig>::const_iterator it = indexConfigMap.begin(); it != indexConfigMap.end(); ++it)
    {
        factory((*it).second);
    }
}
